ARRAY

Section: SOS CLASS LIBRARY (3S)
Updated: 28/10/1991
Index Return to Main Contents
man2html: unable to open or read file /usr/lib/ms/ms.acc
 

NAME

Array<Entity> - predefined class Array  

SYNOPSIS

#include "<SOS>/include/agg_sos.h"

class Array<Entity> (Index bottom, Index top,
                    sos_Bool based_on_equal = FALSE)
   : Collection<Entity> (based_on_equal)
{
public:
   Index        get_bottom ();
   Index        get_top ();
   Entity       get_nth (Index);
   void         set_nth (Index, Entity);
   void         shift (Index, sos_Int);
   void         rotate (sos_Int);

   // ** Array operators **
   Entity       operator[] (Index);

   // ** sos_Cursor operations **
   Index        current_pos (sos_Cursor);
   sos_Bool     move_cursor (sos_Cursor, Index);
   void         set (sos_Cursor, Entity);

   // ** Redefinitions **
   void         assign (sos_Object);
   sos_Object   remove_at (sos_Cursor);
}
 

DESCRIPTION

The class Array<Entity> provides means for manipulating generic arrays. The type of the elements is stated when the Array type is instantiated. A position of a member within an array is called an Index. Valid indices for a given array lie between the bottom index and the top index which are specified when the array is created. (Methods that overwrite inherited methods are only described in the superclass where they were inherited from - provided that they are semantically equivalent.)

Array::create (ct, bottom, top, based_on_equal)
allows to specify the bottom and the top index of the new Array as well as the inherited create parameter based_on_equal at creation time.

Example: The statement sos_Object_Array::create (ct,-3,3) creates an array of 7 sos_Objects with an index ranging from -3 to 3. The test of membership for elements of the new array will not be based on the equal, but on the identical method. If the provided bottom index is higher than the top index an empty array with card() == 0 will be created.

get_bottom ()
returns the lowest index of this Array.
get_top ()
returns the highest index of this Array.
get_nth (i)
returns the element at the specified array index i.

PRECONDITION: bottom <= i <= top

set_nth (i, e)
replaces the element at the given index position i by the given element e.

PRECONDITION: bottom <= i <= top

shift (start, nbr_elem)
shifts the array elements from index start to top by nbr_elem positions. If nbr_elem > 0, shifting is done to the right, otherwise to the left. If shifting is to the right, the last nbr_elem elements are lost. The nbr_elem members that are shifted to the right from start or to the left from top, respectively, are undefined.

PRECONDITION: bottom <= start, start + nbr_elem <= top

rotate (nbr_elem)
shifts all elements of the array nbr_elem to the right, if nbr_elem > 0, to the left otherwise. Those elements that are shifted out of the array's one side are fed into the array from the other side again. Thus, after rotate is performed all previously contained Array elements are still contained afterwards.
operator[] (i)
returns the Array element at index i.
assign (source)
assigns the value of source to the value of this Array. If this Array is larger than the argument then only the first source.card() entities are overwritten. If this Array is smaller than the argument then only the first card() entities are assigned.

The following methods require an open sos_Cursor(3) as input parameter:

current_pos (c)
returns the current index position of the specified sos_Cursor c.

PRECONDITION: is_valid (c)

move_cursor (c, i)
moves the given sos_Cursor c to the specified Array index position i. It returns TRUE if this is a valid Array index, FALSE otherwise.

PRECONDITION: c.defined_for (self) AND (bottom <= i <= top)

set (c, e)
replaces the element at the current position of sos_Cursor c by the given element e.

PRECONDITION: is_valid (c)

remove_at (c)
removes the element specified by the sos_Cursor c from the Array. This means that this object will be replaced by NO_OBJECT. So far the operation is equivalent to set (c, NO_OBJECT), but it returns additionally the removed object and moves the cursor to the next element.

PRECONDITION: is_valid (c)

 

FILES

<SOS>/src/agg/agg.sos
SOS schema file

<SOS>/src/agg/agg_sos.h
complete schema interface

<SOS>/src/agg/agg_use.h
restricted schema interface

<SOS>/src/agg/agg_ext.h
definition of iterators (automatically included by agg_use.h)

<SOS>/src/agg/Array.c
Array implementation file

<SOS>/lib/sos.a
SOS library
 

SEE_ALSO

sos_Object(3), sos_Aggregate(3), Collection(3), sos_Cursor(3), agg_iterators(3)  

AUTHOR

Bernhard Schiefer, Dietmar Theobald


 

Index

NAME
SYNOPSIS
DESCRIPTION
FILES
SEE_ALSO
AUTHOR

This document was created by man2html, using the manual pages.
Time: 00:37:57 GMT, March 30, 2022